home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Apple Development Tools / MacsBug 6.5.4a6.sit / MacsBug 6.5.4a6 / Building dcmds / dcmd Includes / Dcmd.h next >
Text File  |  1998-09-22  |  9KB  |  272 lines

  1. /*
  2.      File:        dcmd.h
  3.  
  4.      Contains:    MacsBug debugger command interface.
  5.  
  6.      Version:    Technology:    MacsBug
  7.  
  8.                  Release:    6.5.3
  9.  
  10.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  11.  
  12.                  All rights reserved.
  13.  
  14.      Bugs?:        If you find a problem with this file, send the file and version
  15.                  information (from above) and the problem description to:
  16.  
  17.                      Internet:    apple.bugs@applelink.apple.com
  18.                      AppleLink:    APPLE.BUGS
  19.  
  20. */
  21. #ifndef __DCMD__
  22. #define __DCMD__
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. #ifndef __MACHINEEXCEPTIONS__
  28. #include <MachineExceptions.h>
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_ALIGN_SUPPORTED
  36. #pragma options align=mac68k
  37. #endif
  38.  
  39. #if PRAGMA_IMPORT_SUPPORTED
  40. #pragma import on
  41. #endif
  42.  
  43. /* Possible requests from the debugger to the command*/
  44.  
  45. enum {
  46.     dcmdInit                    = 0,                            /* Initialize the Dcmd */
  47.     dcmdDoIt                    = 1,                            /* Normal Dcmd execution */
  48.     dcmdHelp                    = 2,                            /* Display help for Dcmd */
  49.                                                                 /* Requests added to MacsBug in 6.5d10 that are only sent to format 3 or newer dcmds. */
  50.     dcmdSecondaryInit            = 3,                            /* Second time to init after all System patches have been loaded */
  51.     dcmdShutdown                = 4,                            /* Dcmd should remove any patches (if possible) */
  52.     dcmdGetInfo                    = 5                                /* Return dcmd version and pointer to help text */
  53. };
  54.  
  55. /* 68K register file indices into the RegisterFile.*/
  56.  
  57. enum {
  58.     D0Register                    = 0,
  59.     D1Register                    = 1,
  60.     D2Register                    = 2,
  61.     D3Register                    = 3,
  62.     D4Register                    = 4,
  63.     D5Register                    = 5,
  64.     D6Register                    = 6,
  65.     D7Register                    = 7,
  66.     A0Register                    = 8,
  67.     A1Register                    = 9,
  68.     A2Register                    = 10,
  69.     A3Register                    = 11,
  70.     A4Register                    = 12,
  71.     A5Register                    = 13,
  72.     A6Register                    = 14,
  73.     A7Register                    = 15,
  74.     PCRegister                    = 16,
  75.     SRRegister                    = 17                            /* SR is only 16 bits and is stored in the high word */
  76. };
  77.  
  78. /* Heap block types*/
  79.  
  80. enum {
  81.     freeBlock                    = 0,
  82.     nonrelocatableBlock            = 1,
  83.     relocatableBlock            = 2
  84. };
  85.  
  86. /* Structure used to pass information to and from the dcmd.*/
  87. struct dcmdBlock {
  88.     long *                            registerFile;                /* pointer to 68K CPU register set */
  89.     short                             request;                    /* what action we are requested to take */
  90.     Boolean                         aborted;                    /* Set to true if the user types a key while scrolling */
  91.     Boolean                         pad1;                        /* align to word boundary */
  92.     UInt32                             macsBugVersion;                /* version of MacsBug we are running under */
  93.     UInt16                             maxCallback;                /* maximum valid callback we can make */
  94.     UInt8                             currentISA;                    /* ISA of current PC */
  95.     UInt8                             pad2;                        /* align to word boundary */
  96.     ExceptionInformationPowerPC *    theException;                /* Pointer to PowerPC machine state if ISA is PowerPC */
  97.     Ptr                             requestIOBlock;                /* general-purpose input/output data block pointer */
  98. };
  99. typedef struct dcmdBlock dcmdBlock;
  100.  
  101. typedef struct dcmdBlock *dcmdBlockPtr;
  102.  
  103. struct GetInfoRequestBlock {
  104.     Str255                             usageStr;
  105.     Str255                             creditsStr;
  106.     NumVersion                         dcmdVersion;
  107. };
  108. typedef struct GetInfoRequestBlock GetInfoRequestBlock;
  109.  
  110. typedef struct GetInfoRequestBlock *GetInfoRequestBlockPtr;
  111.  
  112. /*
  113.     These are some useful macros for filling in format 3 version and string fields.
  114. */
  115.  
  116. #define dcmdFillVersion(paramPtr, version) \
  117.     * (long *) &((GetInfoRequestBlockPtr) (paramPtr)->requestIOBlock)->dcmdVersion = (version)
  118. #define dcmdFillString(paramPtr, which, theStr) \
  119.     BlockMoveData(theStr, &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->which, (theStr)[0]+1)
  120.  
  121. /*
  122.     MacsBug callback routines that can be called by the dcmd.
  123. */
  124.  
  125. /*
  126.     Draw the text in the Pascal string as one or more lines separated by CR's.
  127.     Each line causes the MacsBug display to be scrolled and the new line to be
  128.     drawn at the bottom. If the user types a key while scrolling then the aborted
  129.     flag is set telling the command to terminate immediately.
  130. */
  131. extern pascal void dcmdDrawLine(ConstStr255Param str);
  132.  
  133. /*
  134.     Draw the text in the Pascal string as a continuation of the current line.
  135.     CR's are not given special treatment.
  136. */
  137. extern pascal void dcmdDrawString(ConstStr255Param str);
  138.  
  139. /*
  140.     Draw a given number of characters starting from the given pointer as a 
  141.     continuation of the current line. CR's are not given special treatment.
  142. */
  143. extern pascal void dcmdDrawText(StringPtr text, short length);
  144.  
  145. /*
  146.     Scrolls the MacsBug display up one line leaving a blank line at the bottom.
  147. */
  148. extern pascal void dcmdScroll(void );
  149.  
  150. /*
  151.     Display the Pascal string in the command line area and wait for a key to be pressed.
  152.     Return TRUE if the user typed Return. All other keys return FALSE. MacsBug saves this
  153.     key and adds it to the command line once the current command completes. Typing any
  154.     key other than Return sets the aborted flag and tells the command to terminate immediately.
  155. */
  156. extern pascal Boolean dcmdDrawPrompt(ConstStr255Param str);
  157.  
  158. /*
  159.     Get the current command line position.
  160. */
  161. extern pascal short dcmdGetPosition(void );
  162.  
  163. /*
  164.     Set the current command line position. This should only be set to a value returned 
  165.     by dcmdGetPosition.
  166. */
  167. extern pascal void dcmdSetPosition(short pos);
  168.  
  169. /*
  170.     Return the next character on the command line or CR if the entire line has been scanned
  171. */
  172. extern pascal short dcmdGetNextChar(void );
  173.  
  174. /*
  175.     Return the next character on the command line or CR if the entire line has been scanned.
  176.     However, the current command line position is not changed.
  177. */
  178. extern pascal short dcmdPeekAtNextChar(void );
  179.  
  180. /*
  181.     Copy all characters from the command line to the parameter string until a delimiter
  182.     is found or the end of the command line is reached. A delimiter is either a space,
  183.     a comma or a CR. Both single and double quoted strings are allowed on the command
  184.     line. However, the leading and trailing quotes must be of the same type. The parameter
  185.     string is returned without the quotes. This function returns the delimiter.
  186. */
  187. extern pascal short dcmdGetNextParameter(Str255 str);
  188.  
  189. /*
  190.     Parse the command line for the next expression. All expressions are evaluated to 32 bits.
  191.     This function returns the delimiter after the expression. The possible delimiters are
  192.     space, comma and CR. Space is not treated as a delimiter in the middle of expressions,
  193.     unless it's before a binary '-' (minus). For instance, '1 + 2' will return a value of 3
  194.     and the delimiter will be the char following the 2. '1 - 2' will return a value of 1
  195.     and the delimeter is the space character before the '-'. This is done so that built-in
  196.     commands and dcmds can properly parse '-x' options. The return parameter 'ok' tells if
  197.     the expression was parsed successfully as far as syntax is concerned.
  198. */
  199. extern pascal short dcmdGetNextExpression(long *value, Boolean *ok);
  200.  
  201. /*
  202.     Copy the break message MacsBug displayed the last time it was entered into str.
  203.     This may contain multiple lines separated by CR's.
  204. */
  205. extern pascal void dcmdGetBreakMessage(Str255 str);
  206.  
  207. /*
  208.     Return a symbolic representation for address in str. If no symbol can be found
  209.     then an empty string is returned. The format of the symbol returned is Name+00000.
  210. */
  211. extern pascal void dcmdGetNameAndOffset(long address, Str255 str);
  212.  
  213. /*
  214.     Return the trap name for the trap number. If no symbol can be found
  215.     then an empty string is returned.
  216. */
  217. extern pascal void dcmdGetTrapName(short trapNumber, Str255 trapName);
  218.  
  219. /*
  220.     Return a pointer the macro name for the given value. If no macro can be found
  221.     then a nil is returned.
  222. */
  223. extern pascal StringPtr dcmdGetMacroName(long value);
  224.  
  225. /*
  226.     When a debugger command is called, the debugger's world (low memory) is installed.
  227.     Commands that want to reference the user's world can swap back and forth between the
  228.     two worlds by making this call. This procedure does nothing in MacsBug; there is no
  229.     distinction between user and debugger worlds. It is included to support other
  230.     debuggers that might want to take advantage of it.
  231. */
  232. extern pascal void dcmdSwapWorlds(void );
  233.  
  234. /*
  235.     Toggle between the user and debugger displays. The first call restores the user's actual screen.
  236.     The second call restores the debugger's screen.
  237. */
  238. extern pascal void dcmdSwapScreens(void );
  239.  
  240. /*
  241.     Walk through the blocks in the current heap, calling DoThis for each block. DoThis should
  242.     be a procedure of the form:
  243.                 
  244.         pascal void DoThis (long blockAddress, long blockLength, long addrOfMasterPtr,
  245.                              short blockType, Boolean locked, Boolean purgeable, Boolean resource)
  246.  
  247.     The blockAddress and blockLength pertain to the data in the heap block, not including
  248.     the block header. The addrOfMasterPtr is the master pointer's location in the heap,
  249.     not the value of the master ptr. The blockType is defined by the constants freeBlock,
  250.     nonrelocatableBlock and relocatableBlock. The booleans locked, purgeable and resource
  251.     reflect the state of the block.
  252. */
  253.  
  254. typedef pascal void (*DoThisPtr)(long blockAddress, long blockLength, long addrOfMasterPtr, short blockType, Boolean locked, Boolean purgeable, Boolean resource);
  255.  
  256. extern pascal void dcmdForAllHeapBlocks(DoThisPtr DoThis);
  257.  
  258. #if PRAGMA_IMPORT_SUPPORTED
  259. #pragma import off
  260. #endif
  261.  
  262. #if PRAGMA_ALIGN_SUPPORTED
  263. #pragma options align=reset
  264. #endif
  265.  
  266. #ifdef __cplusplus
  267. }
  268. #endif
  269.  
  270. #endif /* __DCMD__ */
  271.  
  272.